package warbots.gameplay;

import warbots.gameplay.exceptions.GameplayException;

public class Game {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Game game = new Game();

			GamePlay gamePlay = game.createGame("sonia", "ido", new Map()); // no map();
			gamePlay.init();
			gamePlay.gameLoop();
		} catch (GameplayException e) {
			e.printStackTrace();
		}
	}

	public GamePlay createGame(String name1, String name2, Map map) {

		GamePlay gameplay = null;
		try {
			Player player1 = createPlayer(name1, map);
			Player player2 = createPlayer(name2, map);

			gameplay = new GamePlay(map, player2, player1);
		} catch (GameplayException e) {
			System.out.println("Cannot start game, check initial parameters");
		}

		return gameplay;
	}

	public Player createPlayer(String name, Map map) throws GameplayException {
		Player player = new Player(name);
		player.deposit(map.getSum());

		return player;
	}

}
